#include "scenehorizon.h"

SceneHorizon::SceneHorizon(QWidget *parent) :
    QWidget(parent)
{
}

void SceneHorizon::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    QRect rectangle_dessin(0, 0, 200, 200);
    painter.drawArc(rectangle_dessin, 0, (16*360));
    QLine line(QPoint(0.,100.), QPoint(200., 100.));
    QPoint centre_line(100., 100.);

    line.setP1(QPoint(
                        (((line.p1().x() - centre_line.x()) * cos(angle_line)) +
                        ((line.p1().y() - centre_line.y()) * sin(angle_line))
                        ) + centre_line.x()
                        ,
                        (((line.p1().y() - centre_line.y()) * cos(angle_line)) -
                        ((line.p1().x() - centre_line.x()) * sin(angle_line))
                        ) + centre_line.y()
                     )
               );
    line.setP2(QPoint(
                       (((line.p2().x() - centre_line.x()) * cos(angle_line)) +
                       ((line.p2().y() - centre_line.y()) * sin(angle_line))
                       ) + centre_line.x()
                       ,
                       (((line.p2().y() - centre_line.y()) * cos(angle_line)) -
                       ((line.p2().x() - centre_line.x()) * sin(angle_line))
                       ) + centre_line.y()
                    )
               );
    painter.drawLine(line);
}

void SceneHorizon::setAngle(float angle)
{
    angle_line = PI*angle/180.;
    update();
}
